/* 
 * Copyright 2011 Karl Pauls karlpauls@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.kalpatec.pojosr.framework.launch;

import java.io.PrintStream;
import java.net.URI;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.Manifest;

public class BundleDescriptor
{
    private final ClassLoader m_loader;
    private final URI m_uri;
    private final Manifest m_mf;

    public BundleDescriptor(ClassLoader loader, URI url,
            Manifest mf)
    {
        m_loader = loader;
        m_uri = url;
        m_mf = mf;
    }

    public ClassLoader getClassLoader()
    {
        return m_loader;
    }

    public URI getURI()
    {
        return m_uri;
    }

    public String toString()
    {
        return m_uri.toString();
    }

    public Attributes getAttributes()
    {
    	return m_mf.getMainAttributes();
    }
    
    public void print( PrintStream out ) {
    	final Attributes attr = getAttributes();
    	
    	out.printf("\n\n[%s]\n", getURI());
    	
		for( Map.Entry<Object, Object> e : attr.entrySet() ) {
			
			out.printf( "\tENTRY [ %s ] = [%s]\n", String.valueOf(e.getKey()), String.valueOf(e.getValue()));			
		}
    	out.printf("\n\n");
    }
}
